'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { DATE, STRING, UUIDV4, UUID } = Sequelize;

    await queryInterface.createTable('members', {
      name: {
        type: STRING(64),
        comment: '用户名',
        allowNull: false,
      },
      password: {
        type: STRING,
        comment: '密码'
      },
      age: {
        type: STRING(3),
        comment: '年龄',
        allowNull: true,
      },
      gender: {
        type: STRING(1),
        defaultValue: 'F',
        comment: '性别',
        allowNull: true,
      },
      province_code: {
        type: STRING(8),
        allowNull: true,
        comment: '省-code'
      },
      city_code: {
        type: STRING(8),
        allowNull: true,
        comment: '市-code'
      },
      county_code: {
        type: STRING(8),
        allowNull: true,
        comment: '区-code'
      },
      address: {
        type: STRING(128),
        allowNull: true,
        comment: '地址'
      },
      uuid: {
        type: UUID,
        defaultValue: UUIDV4,
        primaryKey: true
      },
      created_at: DATE,
      updated_at: DATE
    })
  },

  down: async (queryInterface, Sequelize) => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('books');
  }
};
